/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controllers;

import Entities.Klant;
import Interfaces.RegistrerenInterface;
import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;

/**
 *
 * @author Andy
 */
@Named
@RequestScoped
public class ControllerRegistreren implements Serializable {

    @Inject
    private RegistrerenInterface registrerenInterface;
    private Klant klant = new Klant();
    private String paswoord2;
    private String foutmelding;

    public String getFoutmelding() {
        return foutmelding;
    }

    public void setFoutmelding(String foutmelding) {
        this.foutmelding = foutmelding;
    }
    
    

    public ControllerRegistreren() {
    }

    public Klant getKlant() {
        return klant;
    }

    public void setKlant(Klant klant) {
        this.klant = klant;
    }

    public String getPaswoord2() {
        return paswoord2;
    }

    public void setPaswoord2(String paswoord2) {
        this.paswoord2 = paswoord2;
    }

    public String insertKlant() {

        //kijken of wachtwoorden hetzelfde zijn
        if (klant.getWachtwoord().equals(getPaswoord2())) {

            //kijken of klant al bestaaat
            if (registrerenInterface.insertKlant(klant)) {
                return "index.xhtml";
            } else {
                foutmelding = "Deze klant bestaat al!";
                return "registratie.xhtml";
            }
        } else {

            return "registratie.xhtml";

            
        }
    }
}
